//
//  BTHistorySearchM.m
//  BaxTer
//
//  Created by 陈武琦 on 16/9/13.
//  Copyright © 2016年 陈武琦. All rights reserved.
//

#import "BTHistorySearchM.h"
  static LKDBHelper* db;
@implementation BTHistorySearchM

//重载选择 使用的LKDBHelper
+(LKDBHelper *)getUsingLKDBHelper
{
  
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        
        NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString* documentsDirectory = [paths objectAtIndex:0];
        NSString* savePath = [documentsDirectory stringByAppendingPathComponent:@"baxTer/baxTer.db"];
        //        if (![[NSFileManager defaultManager] fileExistsAtPath:savePath]) {
        //
        //            [[NSFileManager defaultManager] createDirectoryAtPath:savePath withIntermediateDirectories:YES attributes:nil error:nil];
        //        }
        //        NSString* dbPath = [savePath stringByAppendingPathComponent:@"baxTer.db"];
        
        db = [[LKDBHelper alloc]initWithDBPath:savePath];
        //or
        //        db = [[LKDBHelper alloc]init];
    });
    return db;
}


// 将要插入数据库
+(BOOL)dbWillInsert:(NSObject *)entity
{
   
    LKErrorLog(@"will insert : %@",NSStringFromClass(self));
    return YES;
}
//已经插入数据库
+(void)dbDidInserted:(NSObject *)entity result:(BOOL)result
{
    LKErrorLog(@"did insert : %@",NSStringFromClass(self));
}


@end
